package com.aerozhonghuan.logisticsmall.modules.home.logic;

import android.content.Context;

import com.aerozhonghuan.logisticsmall.framework.base.URLs;
import com.aerozhonghuan.logisticsmall.modules.common.entity.GoodsObject;
import com.aerozhonghuan.logisticsmall.modules.home.beans.ActivityDetailBean;
import com.aerozhonghuan.logisticsmall.modules.home.beans.ActivityListBean;
import com.aerozhonghuan.logisticsmall.modules.home.search.beans.SearchBean;
import com.aerozhonghuan.logisticsmall.widget.ProgressDialogIndicator;
import com.aerozhonghuan.oknet2.CommonCallback;
import com.aerozhonghuan.oknet2.RequestBuilder;
import com.google.gson.reflect.TypeToken;

/**
 * Created by ChenLin on 2019/5/20 14:13.Email&WeChat:7877409@163.com
 */
public class HomePageInfoRequest {

    public static void activityList(Context context, ProgressDialogIndicator dialog, CommonCallback<ActivityListBean> callback) {
        TypeToken<ActivityListBean> type = new TypeToken<ActivityListBean>() {
        };
        callback.setResponseType(type);
        RequestBuilder.with(context)
                .URL(URLs.ACTIVITY_LIST_URL)
                .progress(dialog)
                .onSuccess(callback).excute();
    }

    public static void search(String keyword, String pageSize, String pageNumber, Context context,
                              ProgressDialogIndicator dialog, CommonCallback<SearchBean> callback) {
        TypeToken<SearchBean> type = new TypeToken<SearchBean>() {
        };
        callback.setResponseType(type);
        RequestBuilder.with(context)
                .URL(URLs.SEARCH)
                .progress(dialog)
                .para("keyword", keyword)
                .para("pageSize", pageSize)
                .para("pageNumber", pageNumber)
                .onSuccess(callback).excute();
    }

    public static void list(String cid, String pageSize, String pageNumber, Context context,
                            ProgressDialogIndicator dialog, CommonCallback<SearchBean> callback) {
        TypeToken<SearchBean> type = new TypeToken<SearchBean>() {
        };
        callback.setResponseType(type);
        RequestBuilder.with(context)
                .URL(URLs.LIST)
                .progress(dialog)
                .para("cid", cid)
                .para("pageSize", pageSize)
                .para("pageNumber", pageNumber)
                .onSuccess(callback).excute();

    }

    public static void detail(String pvsid, Context context,
                              ProgressDialogIndicator dialog, CommonCallback<GoodsObject> callback) {
        TypeToken<GoodsObject> type = new TypeToken<GoodsObject>() {
        };
        callback.setResponseType(type);
        RequestBuilder.with(context)
                .URL(URLs.DETAIL)
                .progress(dialog)
                .para("pvsid", pvsid)
                .onSuccess(callback).excute();
    }

    /**
     * 活动详情
     */
    public static void activityDetail(String id, Context context, ProgressDialogIndicator dialog, CommonCallback<ActivityDetailBean> callback) {
        TypeToken<ActivityDetailBean> type = new TypeToken<ActivityDetailBean>() {
        };
        callback.setResponseType(type);
        RequestBuilder.with(context)
                .URL(URLs.ACTIVITY_DETAIL)
                .progress(dialog)
                .para("id", id)
                .onSuccess(callback).excute();
    }
}
